﻿// ------------------------------------------------------------------------
// 版权信息
// 版权归重庆虫儿飞科技有限公司所有。
// 所有权利保留。
// 官方网站：https://netokit.com
// 许可证信息
// Neto.Kit 项目主要遵循 MIT 许可证和 Apache 许可证（版本 2.0）进行分发和使用。
// 许可证的完整文本可以在源代码树根目录中的 LICENSE-APACHE 和 LICENSE-MIT 文件中找到。
// 
// 使用条款
// 使用本代码应遵守相关法律法规和许可证的要求。
// 
// 免责声明
// 对于因使用本代码而产生的任何直接、间接、偶然、特殊或后果性损害，我们不承担任何责任。
// 
// 其他重要信息
// Neto.Kit 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。
// 有关 Neto.Kit 项目的其他详细信息，请参阅位于源代码树根目录中的 COPYRIGHT 和 DISCLAIMER 文件。
// 
// 更多信息
// 请访问 https://netokit.com 获取更多关于 Neto.Kit 项目的许可证和版权信息。
// ------------------------------------------------------------------------

public static class LoggingExtension
{
    //------------------------------------------DEBUG------------------------------------------//

    /// <summary>
    ///     格式化并写入调试日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogDebug(0, exception, "Error while processing request from {Address}", address)</example>
    public static void Debug(this ILogger logger, EventId eventId, Exception? exception, string? message = null,
        params object?[] args)
    {
        logger.LogDebug(eventId, exception, message, args);
    }

    /// <summary>
    ///     格式化并写入调试日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogDebug(0, "Processing request from {Address}", address)</example>
    public static void Debug(this ILogger logger, EventId eventId, string? message = null, params object?[] args)
    {
        logger.LogDebug(eventId, message, args);
    }

    /// <summary>
    ///     格式化并写入调试日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogDebug(exception, "Error while processing request from {Address}", address)</example>
    public static void Debug(this ILogger logger, Exception? exception, string? message = null, params object?[] args)
    {
        logger.LogDebug(exception, message, args);
    }

    /// <summary>
    ///     格式化并写入调试日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogDebug("Processing request from {Address}", address)</example>
    public static void Debug(this ILogger logger, string? message = null, params object?[] args)
    {
        logger.LogDebug(message, args);
    }

    //------------------------------------------TRACE------------------------------------------//

    /// <summary>
    ///     格式化并写入跟踪日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogTrace(0, exception, "Error while processing request from {Address}", address)</example>
    public static void Trace(this ILogger logger, EventId eventId, Exception? exception, string? message = null,
        params object?[] args)
    {
        logger.LogTrace(eventId, exception, message, args);
    }

    /// <summary>
    ///     格式化并写入跟踪日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogTrace(0, "Processing request from {Address}", address)</example>
    public static void Trace(this ILogger logger, EventId eventId, string? message = null, params object?[] args)
    {
        logger.LogTrace(eventId, message, args);
    }

    /// <summary>
    ///     格式化并写入跟踪日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogTrace(exception, "Error while processing request from {Address}", address)</example>
    public static void Trace(this ILogger logger, Exception? exception, string? message = null, params object?[] args)
    {
        logger.LogTrace(exception, message, args);
    }

    /// <summary>
    ///     格式化并写入跟踪日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogTrace("Processing request from {Address}", address)</example>
    public static void Trace(this ILogger logger, string? message = null, params object?[] args)
    {
        logger.LogTrace(message, args);
    }

    //------------------------------------------INFORMATION------------------------------------------//

    /// <summary>
    ///     格式化并写入信息日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogInformation(0, exception, "Error while processing request from {Address}", address)</example>
    public static void Information(this ILogger logger, EventId eventId, Exception? exception, string? message = null,
        params object?[] args)
    {
        logger.LogInformation(eventId, exception, message, args);
    }

    /// <summary>
    ///     格式化并写入信息日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogInformation(0, "Processing request from {Address}", address)</example>
    public static void Information(this ILogger logger, EventId eventId, string? message = null, params object?[] args)
    {
        logger.LogInformation(eventId, message, args);
    }

    /// <summary>
    ///     格式化并写入信息日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogInformation(exception, "Error while processing request from {Address}", address)</example>
    public static void Information(this ILogger logger, Exception? exception, string? message = null,
        params object?[] args)
    {
        logger.LogInformation(exception, message, args);
    }

    /// <summary>
    ///     格式化并写入信息日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogInformation("Processing request from {Address}", address)</example>
    public static void Information(this ILogger logger, string? message = null, params object?[] args)
    {
        logger.LogInformation(message, args);
    }

    //------------------------------------------WARNING------------------------------------------//

    /// <summary>
    ///     格式化并写入警告日志消息.
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogWarning(0, exception, "Error while processing request from {Address}", address)</example>
    public static void Warning(this ILogger logger, EventId eventId, Exception? exception, string? message = null,
        params object?[] args)
    {
        logger.LogWarning(eventId, exception, message, args);
    }

    /// <summary>
    ///     格式化并写入警告日志消息.
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogWarning(0, "Processing request from {Address}", address)</example>
    public static void Warning(this ILogger logger, EventId eventId, string? message = null, params object?[] args)
    {
        logger.LogWarning(eventId, message, args);
    }

    /// <summary>
    ///     格式化并写入警告日志消息.
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogWarning(exception, "Error while processing request from {Address}", address)</example>
    public static void Warning(this ILogger logger, Exception? exception, string? message = null, params object?[] args)
    {
        logger.LogWarning(exception, message, args);
    }

    /// <summary>
    ///     格式化并写入警告日志消息.
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogWarning("Processing request from {Address}", address)</example>
    public static void Warning(this ILogger logger, string? message = null, params object?[] args)
    {
        logger.LogWarning(message, args);
    }

    //------------------------------------------ERROR------------------------------------------//

    /// <summary>
    ///     格式化并写入错误日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogError(0, exception, "Error while processing request from {Address}", address)</example>
    public static void Error(this ILogger logger, EventId eventId, Exception? exception, string? message = null,
        params object?[] args)
    {
        logger.LogError(eventId, exception, message, args);
    }

    /// <summary>
    ///     格式化并写入错误日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogError(0, "Processing request from {Address}", address)</example>
    public static void Error(this ILogger logger, EventId eventId, string? message = null, params object?[] args)
    {
        logger.LogError(eventId, message, args);
    }

    /// <summary>
    ///     格式化并写入错误日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogError(exception, "Error while processing request from {Address}", address)</example>
    public static void Error(this ILogger logger, Exception? exception, string? message = null, params object?[] args)
    {
        logger.LogError(exception, message, args);
    }

    /// <summary>
    ///     格式化并写入错误日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogError("Processing request from {Address}", address)</example>
    public static void Error(this ILogger logger, string? message = null, params object?[] args)
    {
        logger.LogError(message, args);
    }

    //------------------------------------------CRITICAL------------------------------------------//

    /// <summary>
    ///     格式化并写入关键日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogCritical(0, exception, "Error while processing request from {Address}", address)</example>
    public static void Critical(this ILogger logger, EventId eventId, Exception? exception, string? message = null,
        params object?[] args)
    {
        logger.LogCritical(eventId, exception, message, args);
    }

    /// <summary>
    ///     格式化并写入关键日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="eventId">与日志关联的事件id</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogCritical(0, "Processing request from {Address}", address)</example>
    public static void Critical(this ILogger logger, EventId eventId, string? message = null, params object?[] args)
    {
        logger.LogCritical(eventId, message, args);
    }

    /// <summary>
    ///     格式化并写入关键日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="exception">异常日志</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogCritical(exception, "Error while processing request from {Address}", address)</example>
    public static void Critical(this ILogger logger, Exception? exception, string? message = null,
        params object?[] args)
    {
        logger.LogCritical(exception, message, args);
    }

    /// <summary>
    ///     格式化并写入关键日志消息
    /// </summary>
    /// <param name="logger">The <see cref="ILogger" /> to write to.</param>
    /// <param name="message">消息内容，支持格式化。例如: <c>"User {User} logged in from {Address}"</c></param>
    /// <param name="args">包含零个或多个要格式化的对象的对象数组.</param>
    /// <example>logger.LogCritical("Processing request from {Address}", address)</example>
    public static void Critical(this ILogger logger, string? message = null, params object?[] args)
    {
        logger.LogCritical(message, args);
    }
}